package cn.hairui.blog.service;

import cn.hairui.blog.dao.TypeMapper;
import cn.hairui.blog.entity.Type;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 分类表 服务实现类
 * </p>
 *
 * @author laoganbu
 * @since 2020-04-06
 */
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements TypeService {

    @Autowired
    private TypeMapper typeMapper;

    @Override
    public int count() {
        return typeMapper.count();
    }

    @Override
    public List<Map> selectByShowFlag(String showFlag, int count) {
        if (count == -1) {
            return typeMapper.selectByShowFlag(showFlag);
        } else {
            return typeMapper.selectByShowFlagLimit(showFlag, count);
        }
    }

    @Override
    public List<Map> listByManageShow() {
        return typeMapper.listByManageShow();
    }

}
